package com.Jshop.order.listener;

import com.Jshop.order.service.OrderService;
import com.Jshop.order.utils.PayHelper;
import com.Jshop.order.utils.PayState;
import com.github.wxpay.sdk.WXPayUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import sun.rmi.runtime.Log;

import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.TimeUnit;


@Component
@RabbitListener(queues = "orderListenerQueue")
public class OrderMessageListener {

    private final static String SUCCESS = "SUCCESS";

    @Resource
    private OrderService orderService;

    @Resource
    private PayHelper payHelper;



    /**
     * 监听 mq的消息
     * @param message xml格式的消息
     */
    @RabbitHandler
    public void getMessage(String message) throws Exception {
//                    orderService.deleteOrder(outTradeNo);

        //对微信服务器
        //查询订单支付状态
        //并修改本地订单状态
        PayState payState = this.payHelper.queryOrder(Long.valueOf(message));
        System.out.println("订单" + message + "  支付状态  " + payState);
    }

}
